<?php
/**
 * Created by PhpStorm.
 * User: jocky
 * Date: 26/08/2017
 * Time: 15:12
 */

//生成原始的二维码(不生成图片文件)
//function scerweima2($url=''){
//    require_once 'phpqrcode.php';
//
//    $value = $url;                  //二维码内容
//    $errorCorrectionLevel = 'M';    //容错级别
//    $matrixPointSize = 10;           //生成图片大小
//   // 生成二维码图片
//    $QR = QRcode::png($value,false,$errorCorrectionLevel, $matrixPointSize, 2);
//}
if (Yii::$app->user->identity->agentID==0) {
    $agentID =10000001;
} else {
    $agentID =$userbrokers_id;
}
$url ="http://www.y11.com/reg?brokerId=" . $agentID;
$urls ="http://admin.y11.com/reg?brokerId=". $agentID;
?>
<div class="form-group">
    <div class="col-md-12 col-xs-12 text-center">
        <div id="QRCode" style="display: flex; flex-direction: row; margin: 10px auto;"></div>
        <div id="QRCodes" style="display: flex; flex-direction: row;"></div>
        <table width="100%"><tr><td>子账户开户地址二维码</td><td>代理开户地址二维码</td></tr></table>
    </div>
</div>
<br/>
<div class="form-group">
    <label class="control-label col-md-3 col-xs-3">子账户推广链接</label>
    <div class="col-md-6 col-xs-9">
        <div class="input-group">
            <input type="text" class="form-control" id="recommendUrl"
                   value="<?= $url; ?>" readonly>
            <span class="input-group-btn">
                <button type="button" class="btn btn-default" style="margin-right: 0">
                    <i class="fa fa-copy" style="padding: 0 5px;" title="拷贝"
                       data-clipboard-action="copy" data-clipboard-target="#recommendUrl"></i>
                </button>
            </span>
        </div>
    </div>
</div>

<div class="form-group">
    <label class="control-label col-md-3 col-xs-3">代理推广链接</label>
    <div class="col-md-6 col-xs-9">
        <div class="input-group">
            <input type="text" class="form-control" id="recommendUrl"
                   value="<?= $urls; ?>" readonly>
            <span class="input-group-btn">
                <button type="button" class="btn btn-default" style="margin-right: 0">
                    <i class="fa fa-copy" style="padding: 0 5px;" title="拷贝"
                       data-clipboard-action="copy" data-clipboard-target="#recommendUrl"></i>
                </button>
            </span>
        </div>
    </div>
</div>

<div class="form-group">
    <label class="control-label col-md-3 col-xs-3">推荐码</label>
    <div class="col-md-6 col-xs-9">
        <div class="input-group">
            <input type="text" class="form-control" id="recommendCode"
                   value="<?= $userbrokers_id ?>" readonly>
            <span class="input-group-btn">
                <button type="button" class="btn btn-default" style="margin-right: 0">
                    <i class="fa fa-copy" style="padding: 0 5px;" title="拷贝"
                       data-clipboard-action="copy" data-clipboard-target="#recommendCode"></i>
                </button>
            </span>
        </div>
    </div>
</div>

<?php
$str_split = empty($hierarchy) ? "" : "<div class='ln_solid'></div>";
$str = "";
foreach ($hierarchy as $v) {
if($hierarchy)
    $v['name']="客户人数";
    $str .= "<div class='form-group'>
                <label class='control-label col-md-3 col-xs-3'>" . $v['name'] . "</label>
                <div class='col-md-6 col-xs-9'>
                    <span class='control-label text-right' style='display: block'>
                        " . $v['count'] . " 人
                    </span>
                </div>
            </div>
    ";
}
echo $str_split . $str;
?>

<script>
    $('#QRCode').ready(function () {
        showQRCode('<?=$url;?>');
    });
    $('#QRCodes').ready(function () {
        showQRCode('<?=$urls;?>');
    });
</script>
